package com.anolesoft.yr.mbus.pre.crtl;

import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.yr.mbus.pre.dto.*;
import com.anolesoft.yr.mbus.pre.service.PreInquiryService;
import com.anolesoft.yr.mbus.pre.vo.ObjectQueryVO;
import com.anolesoft.yr.mbus.pre.vo.PreInquiryQueryVO;
import com.anolesoft.yr.mbus.pre.vo.PreOrderQueryVO;
import com.anolesoft.yr.mbus.util.GlobalLoginInfo;
import com.anolesoft.yr.mbus.util.StrCP;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Controller
@CrossOrigin
@RequestMapping(value = "/preInquiry")
public class PreInquiryController {

    /*
    说明：询盘任务回访界面由7部分组成：
     1、工单信息（查询）；2、推广记录信息（如果有查询）；3、拜访记录信息（如果有查询）；4、询盘历史记录信息（如果有查询）；5、客户基础信息（维护）；6、本次询盘记录信息（维护）；7、服务报价单信息（维护）；
     每个部分所需服务：
     1、工单信息（查询）：暂时没有
     2、推广记录信息（如果有查询）：/prePromote/queryByUid，参数：推广记录表主键
     3、拜访记录信息（如果有查询）：/preVisit/queryByUid，参数：拜访记录表主键
     4、询盘历史记录信息（如果有查询）：/preInquiry/queryPreInquiryUid2，参数：推广记录主键；/preInquiry/queryPreInquiryUid3，参数：拜访记录主键；/preInquiry/queryPreInquiryUid4，参数：询盘记录主键
     5、根据选择信息主键查询询盘记录：
     6、客户基础信息（维护）：/preInquiry/save，参数：PreInquirySaveDTO对象
     7、本次询盘记录信息（维护）：/preInquiry/save，参数：PreInquirySaveDTO对象
     8、服务报价单信息（维护）：/preInquiry/save，参数：PreInquirySaveDTO对象
        PreInquirySaveDTO对象中包含：询盘信息（新增）、客户信息（新增、修改）、
        报价单信息（删除后新增）、报价单产品信息（删除后新增）、报价单配件信息（删除后新增）、报价单标记信息（删除后新增）、报价单配件服务信息（删除后新增）、报价单单一服务信息（删除后新增）
     9、服务报价单查询服务级别：/prodServiceValue/queryProdServiceValue3，参数：无
     10、
     */

    @Autowired
    PreInquiryService preInquiryService;

    //新增询盘记录
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult savePreInquiry() throws Exception {//@RequestBody PreInqutry preInqutry
        //询盘信息
        String preInquiryUid = StrCP.createObjuid32(UUID.randomUUID().toString());
        PreInquirySaveDTO preInquirySaveDTO = new PreInquirySaveDTO();
        preInquirySaveDTO.setObjuid(preInquiryUid);
        preInquirySaveDTO.setFacCode("C");
        preInquirySaveDTO.setPrePromoteUid("91523a6867204cde95f71e5386c17695");
        //preInquirySaveDTO.setPreVisitUid("");
        //preInquirySaveDTO.setPreInquiryUid("");
        preInquirySaveDTO.setInquiryCode("ABC");
        preInquirySaveDTO.setInfoSource("淘宝");
        preInquirySaveDTO.setSourceTime(new Date());
        preInquirySaveDTO.setIntoCompany("星万全");
        preInquirySaveDTO.setClientRegion("西藏");
        preInquirySaveDTO.setClientName("大昭寺");
        preInquirySaveDTO.setContact("12345678");
        preInquirySaveDTO.setContactPerson("大喇嘛");
        preInquirySaveDTO.setClientDemand("客户需求是建立10个服务器集群的机房");
        preInquirySaveDTO.setPurchaseQuantity(1);
        preInquirySaveDTO.setHandlePerson("admin");
        preInquirySaveDTO.setBusinessNature("无");
        preInquirySaveDTO.setSalesPerson("admin");
        preInquirySaveDTO.setReplyTime(new Date());
        preInquirySaveDTO.setReplyWay("网店");
        preInquirySaveDTO.setClientType("无");
        preInquirySaveDTO.setClientRequire("建立机房");
        preInquirySaveDTO.setClientQuality("无");
        preInquirySaveDTO.setNewOldClient(0);
        preInquirySaveDTO.setSuggest("无");
        preInquirySaveDTO.setThisMonthOrder(0);
        preInquirySaveDTO.setFirstOrderTime(new Date());
        preInquirySaveDTO.setNoOrderReason("其他");
        preInquirySaveDTO.setExplains("无");
        preInquirySaveDTO.setRemark("无");
        preInquirySaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
        preInquirySaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
        preInquirySaveDTO.setDelFlag(0);
        preInquirySaveDTO.setCrmBaseType("Insert");

            //新增或修改客户信息
            if(true){
                List crmBaseSaveDTOList = Lists.newArrayList();
                CrmBaseSaveDTO crmBaseSaveDTO = new CrmBaseSaveDTO();
                String crmBaseUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                crmBaseSaveDTO.setObjuid(crmBaseUid);
                crmBaseSaveDTO.setFacCode("C");
                crmBaseSaveDTO.setBaseRegionUid("11111111111111111111111111111111");
                crmBaseSaveDTO.setCrmCode("12345");
                crmBaseSaveDTO.setCrmName("中航工业沈飞");
                crmBaseSaveDTO.setCrmOtherName("沈飞");
                crmBaseSaveDTO.setCrmAddress("辽宁省沈阳市");
                crmBaseSaveDTO.setEstablishTime(new Date());
                crmBaseSaveDTO.setCrmWebsite("www.sf.com");
                crmBaseSaveDTO.setEmail("sf@zh.com");
                crmBaseSaveDTO.setContactPerson("admin");
                crmBaseSaveDTO.setContactNumber("024-12345678");
                crmBaseSaveDTO.setFaxNumber("024-87654321");
                crmBaseSaveDTO.setCrmGrade("高级");
                crmBaseSaveDTO.setLegalPerson("笑哈哈");
                crmBaseSaveDTO.setCompanyType("国企");
                crmBaseSaveDTO.setBank("中国建设银行沈阳分行");
                crmBaseSaveDTO.setAccount("0000000001");
                crmBaseSaveDTO.setTaxNumber("0000000002");
                crmBaseSaveDTO.setRemark("");
                crmBaseSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                crmBaseSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                crmBaseSaveDTO.setDelFlag(0);
                crmBaseSaveDTOList.add(crmBaseSaveDTO);
                preInquirySaveDTO.setCrmBaseSaveDTO(crmBaseSaveDTOList);
            }else{
                List crmBaseUpdateDTOList = Lists.newArrayList();
                CrmBaseUpdateDTO crmBaseUpdateDTO = new CrmBaseUpdateDTO();
                crmBaseUpdateDTO.setFacCode("C");
                crmBaseUpdateDTO.setBaseRegionUid("11111111111111111111111111111111");
                crmBaseUpdateDTO.setCrmCode("12345-U");
                crmBaseUpdateDTO.setCrmName("中航工业沈飞-U");
                crmBaseUpdateDTO.setCrmOtherName("沈飞");
                crmBaseUpdateDTO.setCrmAddress("辽宁省沈阳市-U");
                crmBaseUpdateDTO.setEstablishTime(new Date());
                crmBaseUpdateDTO.setCrmWebsite("www.sf.com");
                crmBaseUpdateDTO.setEmail("sf@zh.com");
                crmBaseUpdateDTO.setContactPerson("admin");
                crmBaseUpdateDTO.setContactNumber("024-12345678");
                crmBaseUpdateDTO.setFaxNumber("024-87654321");
                crmBaseUpdateDTO.setCrmGrade("高级-U");
                crmBaseUpdateDTO.setLegalPerson("笑哈哈-U");
                crmBaseUpdateDTO.setCompanyType("国企-U");
                crmBaseUpdateDTO.setBank("中国建设银行沈阳分行-U");
                crmBaseUpdateDTO.setAccount("0000000001");
                crmBaseUpdateDTO.setTaxNumber("0000000002");
                crmBaseUpdateDTO.setRemark("");
                crmBaseUpdateDTO.setMmUserUid(GlobalLoginInfo.getGlobalLoginUser());
                crmBaseUpdateDTO.setMmTime(GlobalLoginInfo.getGlobalLoginTime());
                crmBaseUpdateDTO.setObjuid("fe5385626123480ca3fe910b562ccf58");
                crmBaseUpdateDTOList.add(crmBaseUpdateDTO);
                preInquirySaveDTO.setCrmBaseUpdateDTO(crmBaseUpdateDTOList);
            }

            //报价单信息
            List preOrderSaveDTOList = Lists.newArrayList();
            String preOrderUid = StrCP.createObjuid32(UUID.randomUUID().toString());
            PreOrderSaveDTO preOrderSaveDTO = new PreOrderSaveDTO();
            preOrderSaveDTO.setObjuid(preOrderUid);
            preOrderSaveDTO.setFacCode("C");
            preOrderSaveDTO.setPreInquiryUid(preInquiryUid);
            preOrderSaveDTO.setQuotationCode("123");
            preOrderSaveDTO.setQuotationDate(new Date());
            preOrderSaveDTO.setQuotationPerson("admin");
            preOrderSaveDTO.setPhone("12345678");
            preOrderSaveDTO.setState(0);
            preOrderSaveDTO.setRemark("无");
            preOrderSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
            preOrderSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
            preOrderSaveDTO.setDelFlag(0);

                //报价单产品信息
                List preOrderProdSaveDTOList = Lists.newArrayList();
                String preOrderProdUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                PreOrderProdSaveDTO preOrderProdSaveDTO = new PreOrderProdSaveDTO();
                preOrderProdSaveDTO.setObjuid(preOrderProdUid);
                preOrderProdSaveDTO.setFacCode("C");
                preOrderProdSaveDTO.setPreOrderUid(preOrderUid);
                preOrderProdSaveDTO.setProdProductionUid("ffafce77d84c49b39d4c75a835b26f61");
                preOrderProdSaveDTO.setProdPackageUid("");
                preOrderProdSaveDTO.setTypeName("备件类");
                preOrderProdSaveDTO.setProdName("备件");
                preOrderProdSaveDTO.setTax(13.0);
                preOrderProdSaveDTO.setRemark("");
                preOrderProdSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                preOrderProdSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                preOrderProdSaveDTO.setDelFlag(0);

                    //报价单配件信息
                    List preOrderPartSaveDTOList = Lists.newArrayList();
                    String preOrderPartUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                    PreOrderPartSaveDTO preOrderPartSaveDTO = new PreOrderPartSaveDTO();
                    preOrderPartSaveDTO.setObjuid(preOrderPartUid);
                    preOrderPartSaveDTO.setFacCode("C");
                    preOrderPartSaveDTO.setPreOrderUid(preOrderUid);
                    preOrderPartSaveDTO.setPreOrderProdUid(preOrderProdUid);
                    preOrderPartSaveDTO.setPartModelUid("aaa");
                    preOrderPartSaveDTO.setSnCode("a");
                    preOrderPartSaveDTO.setQuantity(10);
                    preOrderPartSaveDTO.setInquiryPrice(1000.11);
                    preOrderPartSaveDTO.setOfferPrice(2000.01);
                    preOrderPartSaveDTO.setRemark("");
                    preOrderPartSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                    preOrderPartSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                    preOrderPartSaveDTO.setDelFlag(0);

                        //报价单配件服务信息
                        List preOrderServiceSaveDTOList = Lists.newArrayList();
                        String preOrderServiceUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                        PreOrderServiceSaveDTO preOrderServiceSaveDTO = new PreOrderServiceSaveDTO();
                        preOrderServiceSaveDTO.setObjuid(preOrderServiceUid);
                        preOrderServiceSaveDTO.setFacCode("C");
                        preOrderServiceSaveDTO.setPreOrderUid(preOrderUid);
                        preOrderServiceSaveDTO.setPreOrderProdUid(preOrderProdUid);
                        preOrderServiceSaveDTO.setPreOrderPartUid(preOrderPartUid);
                        preOrderServiceSaveDTO.setServiceName("服务等级");
                        preOrderServiceSaveDTO.setServiceValue("7*24*4");
                        preOrderServiceSaveDTO.setRemark("");
                        preOrderServiceSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                        preOrderServiceSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                        preOrderServiceSaveDTO.setDelFlag(0);
                        preOrderServiceSaveDTOList.add(preOrderServiceSaveDTO);

                    preOrderPartSaveDTO.setPreOrderServiceSaveDTO(preOrderServiceSaveDTOList);
                    preOrderPartSaveDTOList.add(preOrderPartSaveDTO);

                    //报价单标记信息
                    List preOrderMarkSaveDTOList = Lists.newArrayList();
                    String preOrderMarkUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                    PreOrderMarkSaveDTO preOrderMarkSaveDTO = new PreOrderMarkSaveDTO();
                    preOrderMarkSaveDTO.setObjuid(preOrderMarkUid);
                    preOrderMarkSaveDTO.setFacCode("C");
                    preOrderMarkSaveDTO.setPreOrderUid(preOrderUid);
                    preOrderMarkSaveDTO.setPreOrderProdUid(preOrderProdUid);
                    preOrderMarkSaveDTO.setMarkName("报价有效期");
                    preOrderMarkSaveDTO.setMarkContent("本报价2020年10月08日有效");
                    preOrderMarkSaveDTO.setRemark("");
                    preOrderMarkSaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                    preOrderMarkSaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                    preOrderMarkSaveDTO.setDelFlag(0);
                    preOrderMarkSaveDTOList.add(preOrderMarkSaveDTO);

                    //报价单单一服务信息
                    List preOrderServiceOnlySaveDTOList = Lists.newArrayList();
                    String preOrderServiceOnlyUid = StrCP.createObjuid32(UUID.randomUUID().toString());
                    PreOrderServiceOnlySaveDTO preOrderServiceOnlySaveDTO = new PreOrderServiceOnlySaveDTO();
                    preOrderServiceOnlySaveDTO.setObjuid(preOrderServiceOnlyUid);
                    preOrderServiceOnlySaveDTO.setFacCode("C");
                    preOrderServiceOnlySaveDTO.setPreOrderUid(preOrderUid);
                    preOrderServiceOnlySaveDTO.setPreOrderProdUid(preOrderProdUid);
                    preOrderServiceOnlySaveDTO.setName("杨彬");
                    preOrderServiceOnlySaveDTO.setLevel("高级");
                    preOrderServiceOnlySaveDTO.setBeginTime(new Date());
                    preOrderServiceOnlySaveDTO.setEndTime(new Date());
                    preOrderServiceOnlySaveDTO.setOfferPrice(2000.00);
                    preOrderServiceOnlySaveDTO.setRemark("");
                    preOrderServiceOnlySaveDTO.setCcUserUid(GlobalLoginInfo.getGlobalLoginUser());
                    preOrderServiceOnlySaveDTO.setCcTime(GlobalLoginInfo.getGlobalLoginTime());
                    preOrderServiceOnlySaveDTO.setDelFlag(0);
                    preOrderServiceOnlySaveDTOList.add(preOrderServiceOnlySaveDTO);

                preOrderProdSaveDTO.setPreOrderPartSaveDTO(preOrderPartSaveDTOList);
                preOrderProdSaveDTO.setPreOrderMarkSaveDTO(preOrderMarkSaveDTOList);
                preOrderProdSaveDTO.setPreOrderServiceOnlySaveDTO(preOrderServiceOnlySaveDTOList);
                preOrderProdSaveDTOList.add(preOrderProdSaveDTO);

            preOrderSaveDTO.setPreOrderProdSaveDTO(preOrderProdSaveDTOList);
            preOrderSaveDTOList.add(preOrderSaveDTO);

        preInquirySaveDTO.setPreOrderSaveDTO(preOrderSaveDTOList);

        String str = "";
        try {
            str = preInquiryService.savePreInquiry(preInquirySaveDTO);
        } catch (Exception e) {
            str = e.getMessage();
            e.printStackTrace();
        }

        return new AjaxResult(200, str);
    }

    //旧版界面所需服务
    //查询产品名称地址：/prodProduction/queryProdName，参数：无
    //查询配件名称地址：/preInquiry/queryPartModelName，参数：无
    //查询配件询价地址：/preInquiry/querySupBasePart，参数：partModel配件型号
    //查询配件报价地址：/preInquiry/queryCrmBasePartPrice，参数：partModel配件型号
    //查询服务报价地址：/preInquiry/queryCrmBaseServicePrice，参数：prodName服务名称
    //查询服务套餐名称地址：/prodPackage/queryProdPackageName，参数：prodName服务名称
    //查询服务套餐内容地址：/prodPackage/queryProdPackageServiceNameValue，参数speciesName套餐名称
    //查询服务项名称地址：/prodService/queryProdServiceName2，参数：prodName服务名称
    //查询服务项参数地址：/prodServiceValue/queryProdServiceValue2，参数：serviceName服务项名称
    //查询报价单信息地址：/preInquiry/queryPreOrderAll，参数：preInquiryUid询盘记录主键（最后一次）

    //查询配件信息（临时查询，正常应该在配件接口中）
    @RequestMapping(value = "/queryPartModelName", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryPartModelName() throws Exception {
        List partModelQueryVOList = preInquiryService.queryPartModelName();

        String jsons = "";
        jsons += "[";
        if (partModelQueryVOList.size() > 0) {
            for (int i = 0; i < partModelQueryVOList.size(); i++) {
                ObjectQueryVO objectQueryVO = (ObjectQueryVO) partModelQueryVOList.get(i);
                jsons += new Gson().toJson(objectQueryVO);
                if (i < (partModelQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //查询配件询价（临时查询，正常应该在配件询价接口中）
    @RequestMapping(value = "/querySupBasePart", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult querySupBasePart(String partModel) throws Exception {
        List supBasePartQueryVOList = preInquiryService.querySupBasePart(partModel);

        String jsons = "";
        jsons += "[";
        if (supBasePartQueryVOList.size() > 0) {
            for (int i = 0; i < supBasePartQueryVOList.size(); i++) {
                ObjectQueryVO objectQueryVO = (ObjectQueryVO) supBasePartQueryVOList.get(i);
                jsons += new Gson().toJson(objectQueryVO);
                if (i < (supBasePartQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //查询配件报价（临时查询，正常应该在配件报价接口中）
    @RequestMapping(value = "/queryCrmBasePartPrice", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryCrmBasePartPrice(String partModel) throws Exception {
        List crmBasePartPriceQueryVOList = preInquiryService.queryCrmBasePartPrice(partModel);

        String jsons = "";
        jsons += "[";
        if (crmBasePartPriceQueryVOList.size() > 0) {
            for (int i = 0; i < crmBasePartPriceQueryVOList.size(); i++) {
                ObjectQueryVO objectQueryVO = (ObjectQueryVO) crmBasePartPriceQueryVOList.get(i);
                jsons += new Gson().toJson(objectQueryVO);
                if (i < (crmBasePartPriceQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //查询服务报价（临时查询，正常应该在服务报价接口中）
    @RequestMapping(value = "/queryCrmBaseServicePrice", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryCrmBaseServicePrice(String prodName) throws Exception {
        List crmBaseServicePriceQueryVOList = preInquiryService.queryCrmBaseServicePrice(prodName);

        String jsons = "";
        jsons += "[";
        if (crmBaseServicePriceQueryVOList.size() > 0) {
            for (int i = 0; i < crmBaseServicePriceQueryVOList.size(); i++) {
                ObjectQueryVO objectQueryVO = (ObjectQueryVO) crmBaseServicePriceQueryVOList.get(i);
                jsons += new Gson().toJson(objectQueryVO);
                if (i < (crmBaseServicePriceQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //查询报价单信息（回访询盘、生成、驳回）
    @RequestMapping(value = "/queryPreOrderAll", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryPreOrderAll(String preInquiryUid) throws Exception {
        List preOrderQueryVOList = preInquiryService.queryPreOrderAll(preInquiryUid);

        String jsons = "";
        jsons += "[";
        if (preOrderQueryVOList.size() > 0) {
            for (int i = 0; i < preOrderQueryVOList.size(); i++) {
                PreOrderQueryVO preOrderQueryVO = (PreOrderQueryVO) preOrderQueryVOList.get(i);
                jsons += new Gson().toJson(preOrderQueryVO);
                if (i < (preOrderQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //根据主键查询询盘记录，用于询盘回访界面的显示（推广主键查询）
    @RequestMapping(value = "/queryPreInquiryUid2", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryPreInquiryUid2(String prePromoteUid) throws Exception {
        List preInquiryQueryVOList = preInquiryService.queryPreInquiryUid2(prePromoteUid);

        String jsons = "";
        jsons += "[";
        if (preInquiryQueryVOList.size() > 0) {
            for (int i = 0; i < preInquiryQueryVOList.size(); i++) {
                PreInquiryQueryVO preInquiryQueryVO = (PreInquiryQueryVO) preInquiryQueryVOList.get(i);
                jsons += new Gson().toJson(preInquiryQueryVO);
                if (i < (preInquiryQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //根据主键查询询盘记录，用于询盘回访界面的显示（拜访主键查询）
    @RequestMapping(value = "/queryPreInquiryUid3", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryPreInquiryUid3(String preVisitUid) throws Exception {
        List preInquiryQueryVOList = preInquiryService.queryPreInquiryUid3(preVisitUid);

        String jsons = "";
        jsons += "[";
        if (preInquiryQueryVOList.size() > 0) {
            for (int i = 0; i < preInquiryQueryVOList.size(); i++) {
                PreInquiryQueryVO preInquiryQueryVO = (PreInquiryQueryVO) preInquiryQueryVOList.get(i);
                jsons += new Gson().toJson(preInquiryQueryVO);
                if (i < (preInquiryQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

    //根据主键查询询盘记录，用于询盘回访界面的显示（询盘主键查询）
    @RequestMapping(value = "/queryPreInquiryUid4", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResult queryPreInquiryUid4(String preInquiryUid) throws Exception {
        List preInquiryQueryVOList = preInquiryService.queryPreInquiryUid4(preInquiryUid);

        String jsons = "";
        jsons += "[";
        if (preInquiryQueryVOList.size() > 0) {
            for (int i = 0; i < preInquiryQueryVOList.size(); i++) {
                PreInquiryQueryVO preInquiryQueryVO = (PreInquiryQueryVO) preInquiryQueryVOList.get(i);
                jsons += new Gson().toJson(preInquiryQueryVO);
                if (i < (preInquiryQueryVOList.size() - 1)) {
                    jsons += ",";
                }
            }
        }
        jsons += "]";

        return new AjaxResult(200, "SUCCESS", jsons);
    }

}
